﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EstructuraCostoListForm.aspx.cs" 
Inherits="UILGestion.ObraAdmin.EstructuraCompras.EstructuraCostoListForm" %>

<%@ Register Assembly="SesarchResultLib" Namespace="SesarchResultLib" TagPrefix="cc2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register src="../../Control/menuObraCtrl.ascx" tagname="menuObraCtrl" tagprefix="uc1" %>
<%@ Register assembly="CustomControls" namespace="CustomControls" tagprefix="cc1" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Estructura Compras</title>

  <%--  <link href="../css/main.css" rel="stylesheet" type="text/css" />--%>
    <link href="../../resources/css/main.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../estilos/_common/styles/fonts.css" />
 <link rel="stylesheet" type="text/css" href="../../estilos/_common/styles/global.css" />
 <link rel="stylesheet" type="text/css" href="../../estilos/_common/styles/theme.css" />
  
     
</head>
<script type="text/javascript">
    function switchViews(obj, row) {
//        var div = document.getElementById(obj.id);
//      

//        if (div.style.display == "none") {
//            div.style.display = "inline";
//            if (row == 'alt') {
//                img.src = "../Images/expand_button_down.png";
//                mce_src = "../Images/expand_button_down.png";
//            }
//            else {
//                img.src = "../Images/expand_button.png";
//                mce_src = "../Images/expand_button.png";
//            }
//            img.alt = "Cerrar para ver otros Reendimientos";
//        }
//        else {
//            div.style.display = "none";
//            if (row == 'alt') {
//                img.src = "../Images/expand_button.png";
//                mce_src = "../Images/expand_button.png";
//            }
//            else {
//                img.src = "../Images/expand_button.png";
//                mce_src = "../Images/expand_button.png";
//            }
//            img.alt = "Expand para mostrar Recursos";
 //       }
    }
    </script>
<body   >
    <form id="form1" runat="server">
     <input id="bitSameEstructura" type="hidden" runat="server" />
       <asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server"  EnablePartialRendering="true">
       
          
    </asp:ToolkitScriptManager>
    <uc1:menuObraCtrl ID="menuObraCtrl1" runat="server" />

 <asp:Panel ID="Panel1" runat="server"
  CssClass="Heading secTitle AreaHeading ms-crm-List-Header "      >
        <asp:Label ID="Label1" runat="server" Text="PARTIDA DE COMPRAS" style="font-size: large; color: #960818"> </asp:Label>
</asp:Panel>  




<asp:Panel ID="pnlMain" runat="server"
     BackColor="White" >

  <asp:UpdatePanel ID="totalesUpdatePanel" runat="server" UpdateMode="Conditional">
  <ContentTemplate>

  <table  >
  <tr>
  <td width="5%"></td>
  <td  width="450px">
  <asp:Panel ID="totalesPanel" runat="server" GroupingText="">
       <table class="table.htmlBar"  >
                      <tr >
                      <td align="right" width="200px" >Total Presupuestos:</td>
                      <td align="right"  width="150px"><asp:Label ID="totalPresupuestoLabel" runat="server" Text=""></asp:Label></td>
                          <td align="right"  width="150px">
                              <asp:Label ID="totalPresupuestoDLLLabel" runat="server" Text=""></asp:Label>
                          </td>
                      </tr>
                      <tr style="background-color:LightYellow;">
                      <td align="right" width="200px" >Total Partidas Compras: </td>
                      <td align="right" width="150px" > <asp:Label ID="estructuraCostoLabel" runat="server" Text=""></asp:Label></td>
                          <td align="right" width="150px">
                              <asp:Label ID="estructuraCostoDLLLabel" runat="server" Text=""></asp:Label>
                          </td>
                      </tr>
                      <tr style="background-color:LightYellow;">
                      <td align="right" width="200px"  >Total Uso Ordenes:</td>
                      <td align="right" width="150px" >
                          <asp:Label ID="totalOCLabel" runat="server"></asp:Label>
                          </td>
                          <td align="right" width="150px" >
                              <asp:Label ID="totalOCDLLLabel" runat="server"></asp:Label>
                          </td>
                      </tr>
                      <tr>
                          <td align="right" width="200px" >
                              Total Saldo:
                          </td>
                          <td align="right" width="150px">
                              <asp:Label ID="totalSaldoSolLBL" runat="server"></asp:Label>
                          </td>
                          <td align="right" width="150px">
                              <asp:Label ID="totalSaldoDolLBL" runat="server"></asp:Label>
                          </td>
                      </tr>
                      </table>
      </asp:Panel>
  </td>
 
  </table>
    
             
          
 </ContentTemplate>
                  </asp:UpdatePanel>  
     



 
   
     <input id="idObra" type="hidden" runat="server" />
      <asp:UpdatePanel ID="estructuraUpdate" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
     <table>
     <tr class="ms-crm-AdvFind-TitleArea">
     <td>
      Estructura: <cc1:DropDownCC ID="EstructuraDropDownList" runat="server" AutoPostBack="true"  Width="250px" OnSelectedIndexChanged="onSelectChanged" />
     </td>
     <td width="150px" align="right">
      <asp:Button ID="refreshButton" runat="server" CssClass="ms-crm-List-Header" 
                            onclick="actualizarButton_Click" Text="Actualizar " />
                            </td>
     <td>
                        <asp:Button ID="importButton" runat="server" CssClass="ms-crm-List-Header" 
                            Text="Importar E/C" />
     </td>
     <td width="120px">
 <asp:UpdateProgress ID="UpdateProgress1" runat="server" >
                    <ProgressTemplate>
                       
                        <img src="../../App_Resources/images/loader-life.gif" alt="Loading Data" />
                    </ProgressTemplate>
                </asp:UpdateProgress>
     </td>
     </tr>
     <tr>
     <td colspan="4">
     
                <asp:GridView ID="estructuraGridView" 
                SkinID="GridView" 
                DataKeyNames="idInternal" 
                OnRowDataBound="gvestructura_RowDataBound"
                 onrowediting="EditItem"
                 onrowupdating="UpdateItem"  
                 onrowcancelingedit="CancelEditItem" 
                 
                ShowFooter="true"
                Runat="server"   
                OnRowCreated="itemGridView_RowCreated"
                    > 

                    <Columns>
                        <asp:TemplateField  ItemStyle-Width="35px">
                          <ItemTemplate> 
                            
                              <asp:ImageButton  id="imgdiv" ClientIDMode="Static"
                                BorderColor="Control"  CommandArgument='<%# Container.DataItemIndex %>'
                                alt="Click para ver Recursos"  CommandName='<%# Eval("idInternal") %>'                                
                                 ImageUrl="../../Images/expand_button.png"  
                                runat="server" OnClick="cargaRecursos_click"/> 

                        </ItemTemplate> 
                      </asp:TemplateField>
                           
                        <asp:TemplateField HeaderText="DESCRIPCION" HeaderStyle-Width="360px"  ItemStyle-Width="360px">
                            <ItemTemplate>
                                 <asp:LinkButton ID="editEcostoButton" runat="server" BorderColor="Control" ForeColor="Blue"
                                        CommandArgument='<%# Eval("idInternal")%>' OnClick="editEcostoButton_click" 
                                        Text='<%# Eval("descripcion")%>'>
                                </asp:LinkButton>
                            </ItemTemplate>
                            <EditItemTemplate>
                            <table>
                                <tr>
                                   <td align="right" >
                                    <b>Estructura: </b>
                                    </td>
                                    <td>
                                     <cc1:DropDownCC ID="Estructura2DropDownList" runat="server"   Width="250px"   >
                                       </cc1:DropDownCC>
                                      <cc1:PostTextBox ID="Estructura2TextBox" runat="server" Width="0px" BackColor="Transparent" ReadOnly="true"  Text='<%# Eval("idPadre")%>'></cc1:PostTextBox>
                                   </td>
                                   </tr>
                                   <tr>
                                <td align="right">
                                <b>Descripcion:  </b>
                                  </td>
                                 <td> 

                                    <cc1:PostTextBox ID="descripcionEditTextBox" runat="server"     Width="250px"    Text='<%# Eval("descripcion")%>' />

                           
                            </td>
                            </tr>
                            </table>
                                
                        
                            </EditItemTemplate>


                            <FooterTemplate>

                             <table>
                                <%--<tr>
                                <td align="right"><b>Estructura:</b>
                                </td>
                                   <td>
                                     <cc1:DropDownCC ID="Estructura2DropDownList" runat="server"  Width="150px"  >
                                       </cc1:DropDownCC>
                                    </td>
                                </tr>--%>
                                   <tr>
                                   <td align="right"><b>Descripcion:</b>
                                </td>
                                <td>
                                   <cc1:PostTextBox ID="descripcionEditTextbox" runat="server"      Width="250px"     Text='<%# Eval("descripcion")%>' />

                            
                            </td>
                            </tr>
                            </table>

                                
                            </FooterTemplate>
                        </asp:TemplateField>
                       
                        <asp:TemplateField HeaderText="TOTAL BASE PARTIDA" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="95px" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="95px">
                            <ItemTemplate>
                              
                                    <asp:Label ID="montoLabel" runat="server" BackColor="Transparent"  Text='<%# Eval("montoStr")%>'>
                                    </asp:Label>
                              
                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:Label ID="montoInsertLabel" runat="server" BackColor="Transparent" 
                                         Text="0.00"> </asp:Label>
                             
                            </FooterTemplate>
                           
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="TOTAL   USO <BR/>  O/C +O/G" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="95px" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="95px">
                            <ItemTemplate>
                                    <asp:Label ID="montoUsoLabel" runat="server" BackColor="Transparent" 
                                         Text='<%# Eval("montoOCUsoStr")%>'>
                                    </asp:Label>
                            </ItemTemplate>
                            <FooterTemplate>
                               
                                    <asp:Label ID="montoUsoInsertLabel" runat="server" BackColor="Transparent" 
                                        Text="0.00">
                                    </asp:Label>
                                
                            </FooterTemplate>
                           
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="TOTAL SALDO PARTIDA" ItemStyle-Width="95px" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="95px">
                            <ItemTemplate>
                                <asp:Label ID="montoDispLabel" runat="server" BackColor="Transparent"   Font-Bold="true"
                                       Text='<%# Eval("montoSaldoStr")%> '
                                       >
                                </asp:Label>
                                
<%--Text='<strong style="color:Red"><%# Eval("montoSaldoStr")%> </strong>'--%>


                            </ItemTemplate>
                            <FooterTemplate>
                                <asp:Label ID="montoDispInsertLabel" runat="server" BackColor="Transparent" 
                                        Text="0.00">
                                    </asp:Label>
                             
                            </FooterTemplate>
                           
                        </asp:TemplateField>


                            <asp:CommandField  ItemStyle-Width="55px"    ButtonType="Image"    ShowEditButton="true"  
                                                                    CancelImageUrl="~/Images/cancel.gif" EditImageUrl="~/Images/edit.gif" 
                                                                    UpdateImageUrl="~/Images/update.gif" />
                        <asp:TemplateField HeaderText="" ItemStyle-Width="50px">
                            <ItemTemplate>
                               
                                <asp:ImageButton  ID="lnkRemove" runat="server" BorderColor="Control" 
                                    CommandArgument='<%# Eval("idInternal")%>' OnClick="Deleteitem" 
                                    OnClientClick="return confirm('Usted quiere eliminar?')" 
                                    ImageUrl="~/Images/delete.gif" />

                                <%--<asp:LinkButton ID="lnkRemove" runat="server" BorderColor="Control" 
                                    CommandArgument='<%# Eval("idInternal")%>' OnClick="Deleteitem" 
                                    OnClientClick="return confirm('Usted quiere eliminar?')" 
                                    Text="&lt;img src=&quot;../Images/delete.gif&quot; /&gt;"></asp:LinkButton>--%>
                            </ItemTemplate>
                            <FooterTemplate>
                              <asp:Button ID="addProvAdd" runat="server" OnClick="AddLinkButton_onClick" Text="Añadir" />
                                <%--<asp:LinkButton ID="AddLinkButton" runat="server" BorderStyle="None" 
                                    OnClick="AddLinkButton_onClick" Text="&lt;img src=&quot;../Images/up.gif&quot; /&gt;" ToolTip="Agregar Titulo de Estructura Costo"></asp:LinkButton>--%>
<%--
                                <asp:LinkButton ID="cancelLinkButton" runat="server" BorderStyle="None" 
                                    OnClick="AddLinkButton_onClick" 
                                    Text="&lt;img src=&quot;../Images/cancel.gif&quot; /&gt;" ToolTip="Cancelar ingreso de Titulo" ></asp:LinkButton>--%>
                            </FooterTemplate>
                            <ItemStyle Width="50px" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                </td>
                                </tr>
                                <tr>
                                    <td colspan="100%">

                                       <asp:UpdatePanel ID="recursoUpdatePanel" runat="server" UpdateMode="Conditional">
                                          <ContentTemplate>
                                        <asp:Panel id='divgrilla'   runat="server"
                                            style="display:none;position:relative;left:25px;">
                                        
                                            <asp:GridView ID="recursoEGridView" Runat="Server"
                                            SkinID="GridView"   DataKeyNames="idInternal" > 
                                               <Columns>
                                                    <asp:BoundField DataField="presupuesto" HeaderText="PRESU."   /> 
                                                    <asp:BoundField DataField="partida" HeaderText="PARTIDA"   /> 
                                                    <asp:BoundField DataField="idRecurso" HeaderText="ID RECU."   /> 
                                                    <asp:BoundField DataField="codigo" HeaderText="CODIGO"   /> 
                                                    <asp:BoundField DataField="descripcion" HeaderText="RECURSO" />
                                                    <asp:BoundField DataField="unidad" HeaderText="UNIDAD" />
                                                    <asp:BoundField DataField="cantidad" HeaderText="CANTIDAD"    ItemStyle-HorizontalAlign="Right"  HeaderStyle-Width="90px"/>
                                                    <asp:BoundField DataField="precio" HeaderText="PRECIO"  ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="90px"  />
                                                    <asp:BoundField DataField="total" HeaderText="TOTAL"  ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="90px"
                                                        />
                                                  
                                                </Columns>
                                            </asp:GridView>  
                                          
                                        </asp:Panel>

                                          </ContentTemplate>
                                            </asp:UpdatePanel>
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                   
           
    
    </asp:GridView> 
    
     </td>
     </tr>
     
     </table>
       
         </ContentTemplate>
                           </asp:UpdatePanel>
       </asp:Panel>
    </form>
</body>
</html>
